#include "wgt_display.h"
#include "ui_wgt_display.h"

#include <QPainter>


Wgt_Display::Wgt_Display(QImage* image, QWidget *parent) :
    QWidget(parent),
    videoFrame(image),
    ui(new Ui::Wgt_Display)
{
    ui->setupUi(this);
    qDebug("[%s]  new", __func__);

    setAttribute(Qt::WA_DeleteOnClose);

    resize(image->width(), image->height());

    qDebug("resize: w:%d, h:%d", width(), height());
}

Wgt_Display::~Wgt_Display()
{
    qDebug("[%s]  delete", __func__);
    delete ui;
}


void Wgt_Display::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.drawImage(videoFrame->rect(), *videoFrame);
}
